﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YunSpace.Application.SiteMgr;
using YunSpace.Core;

namespace YunSpace.Web.Areas.MyTask.Controllers
{
    public class ReportManagerController : ControllerBase
    {
        ClientTrackingApp trackingApp = new ClientTrackingApp();
        SiteClientsApp siteApp = new SiteClientsApp();
        [HttpGet]
        public ActionResult GetGridList(Pagination pagination, string queryJson)
        {           
            var data = new
            {
                rows = trackingApp.GetListFor(pagination, queryJson),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        [HttpGet]
        public ActionResult GetUsersJson()
        {
            var data = siteApp.GetUsersJson();
            return Content(data.ToJson());
        }

        [HttpGet]
        public ActionResult GetClientList()
        {
            var data = siteApp.GetClientList();
            return Content(data.ToJson());
        }

        [HttpGet]
        public ActionResult GetGridDetailList(Pagination pagination, string queryJson)
        {            
            var data = new
            {
                rows = trackingApp.GetDetailListFor(pagination, queryJson),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        [HttpGet]
        public ActionResult GetItemListJson()
        {
            var data = new
            {
                citys = trackingApp.GetItemList("city"),
                activityType = trackingApp.GetItemList("ActivityType"),
                sshy = trackingApp.GetItemList("sshy"),
                SiteType = trackingApp.GetItemList("SiteType"),
                hdjd = trackingApp.GetItemList("hdjd"),
                SiteSupportingFacilities = trackingApp.GetItemList("SiteSupportingFacilities"),
                gszw = trackingApp.GetItemList("gszw"),
                clients = trackingApp.GetClientsList()
            };
            return Content(data.ToJson());
        }
    }
}
